<!-- 公司详情 -->
<template>
    <div>
        <AllOut :nav_value="10">
            <div style="position: relative;" v-loading="loading">
                <TopNav :show_links="true"></TopNav>
                <div class="content_out index_content" style="padding-top:84px;">
                    <b-container fluid>
                        <b-row v-if="loadings">
                            <b-col md="12" sm="12" class="">
                                <div class="zhiwei_main">
                                    <div class="flex jcsb">
                                        <div class="flex company_content_header">
                                            <img src="/img/ele5.png" alt="" v-if="!tantData?.companyLogoUrl" />
                                            <img :src="tantData?.companyLogoUrl" alt="" v-if="tantData.companyLogoUrl" />
                                            <div class="flex flex-d jcsb">
                                                <p class="flex fontz fonts24 fontw700">{{ tantData.companyName }}</p>
                                                <div class="flex zhiweidetail_content_header_main">
                                                    <div class="flex aic">
                                                        <img src="/img/c1.png" alt="" srcset="" />
                                                        <span class="fontz fonts14 gary">{{ dict(tantData.companyType, "company_type") }}</span>
                                                    </div>
                                                    <div class="flex aic" style="margin-left: 60px;">
                                                        <img src="/img/c2.png" alt="" srcset="" />
                                                        <span class="fontz fonts14 gary">{{ dict(tantData.companySize, "company_size") }}</span>
                                                    </div>
                                                    <div class="flex aic" style="margin-left: 60px;">
                                                        <img src="/img/c3.png" alt="" srcset="" />
                                                        <span class="fontz fonts14 gary">{{ dict(tantData.companyIndustry, "company_industry") }}</span>
                                                    </div>
                                                </div>
                                                <p class="fonts18 fontz gary flex aic zhiweidetail_content_header_main">
                                                    <img src="/img/c4.png" alt="" srcset=""
                                                        style="width: 16px;height: 18px;margin-right: 6px;" />
                                                    <span class="fontz fonts14 gary">{{ tantData.address }}</span>
                                                </p>
                                            </div>
                                        </div>
                                        <div class="flex-d aic">
                                            <p class=" fontz fontw700"
                                                style="font-size: 36px;color: #2F6CBC;text-align: center;">{{ total }}</p>
                                            <p class="fontz fonts18 fontw700">在招职位</p>
                                        </div>
                                    </div>
                                    <p class="xindu_div_main_title fontz fonts24 fontw700">公司简介</p>
                                    <p class=" fontz fonts18 " style="margin-top: 30px;">
                                        {{tantData.intro}}
                                    </p>
                                </div>
                                <div class="flex aic conpany_title">
                                    <p @click="navClick(0)" :class="index == 0 ? 'fontw700' : ''"
                                        class="color20 fontz fonts20">
                                        在招职位({{ total }})</p>
                                    <p style="margin-left: 16px;" @click="navClick(1)" :class="index == 1 ? 'fontw700' : ''"
                                        class="color20 fontz fonts20">公示公告({{ totals }})</p>
                                </div>
                                <div class="infoMain_content" v-if="index == 0">
                                    <Information v-for="(item, index) in posData" :key="index" :data="item"
                                        @collectionClick="collectionClick" :indexValue="0" v-if="posData.length != 0"/>
                                        <el-empty
                                    style="width: 100%;height: 500px; background: #f8f9fa;border: 1px solid #CACFD6;margin: auto;"
                                    description="暂无数据" v-if="posData.length == 0" />
                                </div>
                                <div class="infoMain_content" v-if="index == 1">
                                    <!-- <Information v-for="(item, index) in 3" :key="index" /> -->
                                    <div @click="detailClick(item,index)" class="infoMain_content_gongshi" v-for="(item, index) in posDatas" :key="index">
                                        <span class="fontw600 color20 fontz fonts16">{{ item.announcementTitle }}</span>
                                        <span class="color20 fontz fonts16">{{ item.createTime }}</span>
                                    </div>
                                    <el-empty
                                    style="width: 100%;height: 500px; background: #f8f9fa;border: 1px solid #CACFD6;margin: auto;"
                                    description="暂无数据" v-if="posDatas.length == 0" />
                                </div>
                            </b-col>
                        </b-row>
                    </b-container>
                </div>
            </div>
        </AllOut>
    </div>
</template>

<script>
import {
    getDetailTenant,
    companyAnnouncement,
    companyAnnouncementDetail,
    positionList,
    collections
} from "@/api/my.js"
import { dictSect, dictFun,dictFuns } from "@/utils/dictUnit"
export default {
    data() {
        return {
            loading: false,
            loadings: false,
            tantData: {
                companyLogoUrl: ""
            },
            total: 0,
            posData: [],
            ruleFrom: {
                pageNum: 1,
                pageSize: 9999,
                tenantId: "",
            },
            index: 0,
            posDatas: [],
            totals: 0,

        }
    },
    mounted() {
        this.ruleFrom.tenantId = this.getUrlParams().id
        this.positionListApi(this.ruleFrom)
        this.getDetailTenantApi({ tenantId: this.ruleFrom.tenantId })
        this.companyAnnouncementApi({ tenantId: this.ruleFrom.tenantId, pageNum: 1, pageSize: 9999 })
    },
    methods: {
        //----------------------------------------------------- 获取地址栏参数---------------------------------
        getUrlParams() {
            let url = window.location.search; //获取url中"?"符后的字串
            let paramsObj = new Object();
            if (url.indexOf("?") != -1) {
                let str = url.substr(1);
                str = str.split("&");
                for (let i = 0; i < str.length; i++) {

                    paramsObj[str[i].split("=")[0]] = decodeURI(str[i].split("=")[1]);

                }
            }
            return paramsObj;
        },
        navClick(index) {
            this.index = index
        },
        //----------------------------------------------------- 字典--------------------------------- 
        dict(value, res) {
            return dictFuns(value, res)
        },
        // -----------------------------------------------------api--------------------------------------------
        async positionListApi(params) {//首页职位投递
            // this.loading = true
            await positionList(params).then(res => {
                // this.loading = false
                console.log("公司职位投递数据", res);
                this.total = res.total
                this.posData = res.rows
            })
        },
        async companyAnnouncementApi(params) {//公示公告
            // this.loading = true
            await companyAnnouncement(params).then(res => {
                // this.loading = false
                console.log("公司公示公告数据", res);
                this.totals = res.total
                this.posDatas = res.rows
            })
        },
        async getDetailTenantApi(params) {//查询公司详细信息 
            this.loading = true
            await getDetailTenant(params).then(res => {
                this.loading = false
                this.loadings = true
                console.log("获取公司数据", res);
                this.tantData = res.data
            })
        },
        // ----------------------------------------------------//收藏职位-----------------------------------------------
        collectionClick(value) {
            this.collectionApi(value)
        },
        collectionApi(id) {
            collections({ positionId: id }).then(res => {
                this.$message({
                    message: `${res.msg}`,
                    type: 'success',
                });
                // this.info()
                this.positionListApi(this.ruleFrom)
                this.getInfo_()
            }).catch(res => {
                this.$message({
                    message: `${res.msg}`,
                    type: 'error',
                });
            })
        },
        getInfo_() {
            // this.refush = !this.refush
            getInfo().then(res => {
                console.log("个人信息", res);
                sessionStorage.setItem("myInfornation", JSON.stringify(res.data))
            })
        },
        detailClick(item,index){
            this.$router.push(`gsDetail?id=${item.id}&backId=${ this.ruleFrom.tenantId}`)
        }

    }
}
</script>

<style lang="scss" scoped>
.infoMain_content{
    max-height: 1200px;
    overflow-y: auto;
    .infoMain_content_gongshi{
        margin-bottom: 16px;
        padding: 16px;
        border: 1px solid #CACFD6;
        display: flex;
        justify-content: space-between;
    }
}
.conpany_title {
    height: 90px;
    background: #F8F9FA;
    border-radius: 0px 0px 0px 0px;
    opacity: 1;
    border: 1px solid #CACFD6;
    padding: 0 30px;
    margin-bottom: 11px;
}

.xindu_div_main_title {

    color: #3D3D3D;
    position: relative;
    width: 96px;
    margin-top: 40px;

    &::after {
        content: "";
        position: absolute;
        bottom: -18px;
        left: 0;
        width: 100%;
        height: 4px;
        background: #2F6CBC;
        border-radius: 0px 0px 0px 0px;
        opacity: 1;
    }
}

.zhiwei_main {
    padding: 25px 40px;
    background: #FFFFFF;
    border-radius: 0px 0px 0px 0px;
    opacity: 1;
    border: 1px solid #CACFD6;
    margin-bottom: 11px;
}

.company_content_header {
    img {
        width: 120px;
        height: 120px;
        opacity: 1;
        border-radius: 50%;
        margin-right: 33px;
    }
}

.gary {
    color: #898989;
}

.zhiweidetail_content_header_main {
    img {
        width: 18px;
        height: 15px;
        margin-right: 2px;
    }
}
</style>